home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Demos / Component Software / FileFlex 2.0.3.sit / FileFlex 2.0.3 / FileFlex-Director / FileFlex Xtras / -Validation Suite / 00003_performTests 2.ls < prev    next >
Encoding:
Text File  |  1996-07-21  |  8.9 KB  |  311 lines

  1. on tDBSeek
  2.   tTest("DBSeek")
  3.   if the machineType <> 256 then
  4.     set theDBFile to the moviePath & "Test Data:VIDNAME"
  5.   else
  6.     set theDBFile to the moviePath & "TESTDATA\VIDNAME"
  7.   end if
  8.   set indexID to DBUseIndex(theDBFile)
  9.   if indexID < 0 then
  10.     tmsg("==== DBUse returned" && indexID)
  11.     tFail()
  12.   else
  13.     set DBResult to DBTop()
  14.     if DBResult < 0 then
  15.       tmsg("==== DBTop returned" && DBResult)
  16.       tFail()
  17.     else
  18.       set searcher to padIt("TOPPER", 30, " ")
  19.       set seekResult to DBSeek(searcher)
  20.       if seekResult < 0 then
  21.         tmsg("==== DBSeek returned" && seekResult)
  22.         tFail()
  23.       else
  24.         set theRec to DBCurrRecNum()
  25.         if theRec <> 12 then
  26.           tmsg("==== DBCurrRecNum returned" && theRec)
  27.           tFail()
  28.         else
  29.           set DBResult to DBCloseIndex(indexID)
  30.           if DBResult < 0 then
  31.             tmsg("==== DBCloseIndex returned" && DBResult)
  32.             tFail()
  33.           else
  34.             tPass()
  35.           end if
  36.         end if
  37.       end if
  38.     end if
  39.   end if
  40. end
  41.  
  42. on tDBCreateMany
  43.   global dgBlueColor
  44.   set many to 10
  45.   tTest("DBCreate multiple files")
  46.   repeat with DB = 1 to many
  47.     put integer(DB) into field "iteration"
  48.     set the textFont of member "iteration" to "Helvetica"
  49.     set the textSize of member "iteration" to 9
  50.     set the foreColor of member "iteration" to dgBlueColor
  51.     set schema to "CHAR_FLD" & DB & ",C,25"
  52.     put RETURN & "NUM_FLD" & DB & ",N,8,3" after schema
  53.     put RETURN & "MEMO_FLD" & DB & ",M" after schema
  54.     if the machineType <> 256 then
  55.       set theDBFile to the moviePath & "Test Data:" & "TESTM" & DB
  56.     else
  57.       set theDBFile to the moviePath & "TESTDATA\" & "TESTM" & DB
  58.     end if
  59.     set DBResult to DBCreate(theDBFile, 3, schema, "false")
  60.     if DBResult < 0 then
  61.       tmsg("==== dbResult returned" && DBResult & ".  (failed)")
  62.       tFail()
  63.       exit
  64.     end if
  65.     set DBResult to DBCloseAll()
  66.     if DBResult < 0 then
  67.       tmsg("==== DBCloseAll returned" && DBResult & ".  (failed)")
  68.       tFail()
  69.       exit
  70.     end if
  71.     set videoID to DBUse(theDBFile)
  72.     if videoID < 0 then
  73.       tmsg("==== DBUse returned" && videoID & ".  (failed)")
  74.       tFail()
  75.       exit
  76.     end if
  77.     set theFields to DBListFields()
  78.     set fieldCheck to "3" & RETURN & "CHAR_FLD" & DB & ",C,25,0"
  79.     put RETURN & "NUM_FLD" & DB & ",N,8,3" after fieldCheck
  80.     put RETURN & "MEMO_FLD" & DB & ",M,10,0" & RETURN after fieldCheck
  81.     if theFields <> fieldCheck then
  82.       tmsg("==== DBCreate's fields don't match .  (failed)")
  83.       tFail()
  84.       exit
  85.     end if
  86.   end repeat
  87.   set DBResult to DBCloseAll()
  88.   if DBResult < 0 then
  89.     tmsg("==== DBCloseAll returned" && DBResult)
  90.     tFail()
  91.   else
  92.     tPass()
  93.   end if
  94. end
  95.  
  96. on tDBWriteRecX
  97.   global dgBlueColor
  98.   set max to field "iterations"
  99.   put EMPTY into field "iteration"
  100.   tTest("DBWriteRec(X)")
  101.   repeat with i = 1 to max
  102.     put i into field "iteration"
  103.     set the textFont of member "iteration" to "Helvetica"
  104.     set the textSize of member "iteration" to 9
  105.     set the foreColor of member "iteration" to dgBlueColor
  106.     set NUM_FLD to string(integer(i))
  107.     set CHAR_FLD to "Loop [" & integer(i) & "]"
  108.     set theData to "NUM_FLD," & NUM_FLD & RETURN
  109.     put "CHAR_FLD," & CHAR_FLD & RETURN after theData
  110.     set theRec to DBCurrRecNum() + 1
  111.     set DBResult to DBWriteRec("X", theRec, theData)
  112.     if DBResult < 0 then
  113.       tmsg("==== DBWriteRec(X) returned" && DBResult & ".  (failed)")
  114.       tFail()
  115.       exit
  116.     end if
  117.   end repeat
  118.   set numRecs to DBCount()
  119.   if numRecs <> max then
  120.     tmsg("==== DBWriteRec(X) had wrong total record count.  (failed)")
  121.     tFail()
  122.     exit
  123.   end if
  124.   repeat with i = max down to 1
  125.     set theData to integer(i) & RETURN & "N"
  126.     put RETURN & "CHAR_FLD,C,Loop [" & string(integer(i)) & "]" after theData
  127.     put RETURN & "NUM_FLD,N," & string(integer(i)) after theData
  128.     put RETURN & "MEMO_FLD,M" & RETURN after theData
  129.     put integer(i) into field "iteration"
  130.     set DBResult to DBGo(i)
  131.     if DBResult < 0 then
  132.       tmsg("==== DBGo returned" && DBResult & ".  (failed)")
  133.       tFail()
  134.       exit
  135.     end if
  136.     set theNewData to DBGetCurrRecVal("X")
  137.     if theNewData <> theData then
  138.       tmsg("==== Data retrieval mismatch.  (failed)")
  139.       put RETURN & "ORIGINAL DATA: [" & theData & "]" after field "mmsg"
  140.       put RETURN & "ORIGINAL DATA: [" & theNewData & "]" after field "mmsg"
  141.       tFail()
  142.       exit
  143.     end if
  144.   end repeat
  145.   tPass()
  146. end
  147.  
  148. on tDBWriteRecManyX
  149.   global dgBlueColor
  150.   set max to field "iterations"
  151.   set many to 10
  152.   put EMPTY into field "iteration"
  153.   tTest("DBWriteRec(X) multiple files")
  154.   repeat with DB = 1 to many
  155.     if the machineType <> 256 then
  156.       set theDBFile to the moviePath & "Test Data:" & "TESTM" & DB
  157.     else
  158.       set theDBFile to the moviePath & "TESTDATA\" & "TESTM" & DB
  159.     end if
  160.     set theResult to DBUse(theDBFile)
  161.     if theResult < 0 then
  162.       tFail()
  163.       exit
  164.     end if
  165.   end repeat
  166.   repeat with DB = 1 to many
  167.     set DBResult to DBSelect(DB)
  168.     if DBResult < 0 then
  169.       tFail()
  170.       exit
  171.     end if
  172.     repeat with i = 1 to max
  173.       put integer(DB) & "-" & integer(i) into field "iteration"
  174.       set the textFont of member "iteration" to "Helvetica"
  175.       set the textSize of member "iteration" to 9
  176.       set the foreColor of member "iteration" to dgBlueColor
  177.       set NUM_FLD to string(integer(i))
  178.       set CHAR_FLD to "Loop [" & string(integer(DB)) & "-" & integer(i) & "]"
  179.       set theData to "NUM_FLD" & string(integer(DB)) & "," & NUM_FLD & RETURN
  180.       put "CHAR_FLD" & string(integer(DB)) & "," & CHAR_FLD & RETURN after theData
  181.       set theRec to DBCurrRecNum() + 1
  182.       set DBResult to DBWriteRec("X", theRec, theData)
  183.       if DBResult < 0 then
  184.         tmsg("==== DBWriteRec(X) returned" && DBResult & ".  (failed)")
  185.         tFail()
  186.         exit
  187.       end if
  188.     end repeat
  189.     set numRecs to DBCount()
  190.     if numRecs <> max then
  191.       tmsg("==== DBWriteRec(X) had wrong total record count.  (failed)")
  192.       tFail()
  193.       exit
  194.     end if
  195.     repeat with i = max down to 1
  196.       set theData to integer(i) & RETURN & "N"
  197.       put RETURN & "CHAR_FLD" & string(integer(DB)) & ",C,Loop [" & string(integer(DB)) & "-" & string(integer(i)) & "]" after theData
  198.       put RETURN & "NUM_FLD" & string(integer(DB)) & ",N," & string(integer(i)) after theData
  199.       put RETURN & "MEMO_FLD" & string(integer(DB)) & ",M" & RETURN after theData
  200.       put integer(DB) & "-" & integer(i) into field "iteration"
  201.       set the textFont of member "iteration" to "Helvetica"
  202.       set the textSize of member "iteration" to 9
  203.       set the foreColor of member "iteration" to dgBlueColor
  204.       set DBResult to DBGo(i)
  205.       if DBResult < 0 then
  206.         tmsg("==== DBGo returned" && DBResult & ".  (failed)")
  207.         tFail()
  208.         exit
  209.       end if
  210.       set theNewData to DBGetCurrRecVal("X")
  211.       if theNewData <> theData then
  212.         tmsg("==== Data retrieval mismatch.  (failed)")
  213.         put RETURN & "ORIGINAL DATA: [" & theData & "]" after field "mmsg"
  214.         put RETURN & "ORIGINAL DATA: [" & theNewData & "]" after field "mmsg"
  215.         tFail()
  216.         exit
  217.       end if
  218.     end repeat
  219.   end repeat
  220.   set DBResult to DBCloseAll()
  221.   if DBResult < 0 then
  222.     tFail()
  223.     exit
  224.   end if
  225.   put EMPTY into field "iteration"
  226.   tPass()
  227. end
  228.  
  229. on tmsg theMsg
  230.   put theMsg & RETURN after field "mmsg"
  231. end
  232.  
  233. on twait howlong
  234.   set now to the ticks
  235.   repeat while 1 = 1
  236.     if (the ticks - (howlong * 60)) > now then
  237.       exit repeat
  238.     end if
  239.   end repeat
  240. end
  241.  
  242. on tMemStart
  243.   global oldBytes
  244.   set oldBytes to the freeBytes
  245. end
  246.  
  247. on tmemend
  248.   global oldBytes, verboseTest
  249.   if verboseTest then
  250.     set newBytes to the freeBytes
  251.     set theBytes to oldBytes - newBytes
  252.     tmsg("==== Test consumed" && theBytes && "bytes.")
  253.     tmsg("==== The largest contiguous remaining free block is" && the freeBlock && "bytes.")
  254.   end if
  255. end
  256.  
  257. on tTest theTest
  258.   global tName, verboseTest, tNameLen
  259.   set max to field "iterations"
  260.   set tName to theTest
  261.   if max > 1000 then
  262.     put EMPTY into field "mmsg"
  263.   end if
  264.   tMemStart()
  265.   if verboseTest then
  266.     tmsg(EMPTY)
  267.     tmsg("== Testing" && tName & "...")
  268.   else
  269.     put padIt("== Testing" && tName & "...", 50, ".") after field "mmsg"
  270.   end if
  271.   set the text of cast "testName" to "Testing" && tName & "..."
  272.   set the text of cast "iteration" to EMPTY
  273. end
  274.  
  275. on tPass
  276.   global tName, verboseTest, tNameLen
  277.   if verboseTest then
  278.     tmemend()
  279.     tmsg("==== Testing" && tName && "SUCCEEDED.")
  280.   else
  281.     tmsg("SUCCEEDED.")
  282.   end if
  283. end
  284.  
  285. on tFail
  286.   global tName, verboseTest
  287.   if verboseTest then
  288.     tmemend()
  289.     tmsg("==== Testing" && tName && "FAILED.")
  290.     tmsg(EMPTY)
  291.   else
  292.     tmsg("FAILED.")
  293.   end if
  294. end
  295.  
  296. on tClear
  297.   if the number of chars in field "mmsg" > 30000 then
  298.     put EMPTY into field "mmsg"
  299.   end if
  300. end
  301.  
  302. on padIt s, theLen, c
  303.   set newChars to theLen - the number of chars in s
  304.   set pad to EMPTY
  305.   repeat with i = 1 to newChars
  306.     put c after pad
  307.   end repeat
  308.   set theString to s & pad
  309.   return theString
  310. end
  311.